/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.intesal.seguridad.managed;

import java.util.List;
import javax.faces.bean.ManagedBean;
import sv.com.intesal.clases.abstracts.ViewScopedAbstract;
import sv.com.intesal.seguridad.bean.Menu;
import sv.com.intesal.seguridad.controlador.MenuControlador;

/**
 *
 * @author ejerez
 */
@ManagedBean(name = "menuQuickManaged")
public class MenuQuickManaged extends ViewScopedAbstract {

    private Menu selectedMenu;
    private List<Menu> menus;

    public MenuQuickManaged() {
        this.limpiar();
    }

    private void fillGrid() {
        try {
            if (this.menus == null) {
                MenuControlador mc = new MenuControlador();
                this.menus = mc.getMenus();
            }
        } catch (Exception e) {
            e.printStackTrace();
            m.messageError(m.getIerror());
        }
    }

    public void limpiar() {
        this.selectedMenu = new Menu();
        this.menus = null;
        this.fillGrid();
    }

    /*SETTERS AND GETTERS*/
    public List<Menu> getMenus() {
        return menus;
    }

    public void setMenus(List<Menu> menus) {
        this.menus = menus;
    }

    public Menu getSelectedMenu() {
        if (selectedMenu == null) {
            selectedMenu = new Menu();
        }
        return selectedMenu;
    }

    public void setSelectedMenu(Menu selectedMenu) {
        this.selectedMenu = selectedMenu;
    }
}
